package model

type Topic struct {
	Id         int         `json:"id" form:"id" gorm:"primaryKey;autoIncrement"`
	AdminId    int         `json:"admin_id" form:"admin_id" gorm:"column:admin_id;comment:管理员id"`
	Url        string      `json:"url" form:"url" gorm:"column:url;comment:图片url"`
	Title      string      `json:"title" form:"title" gorm:"column:title;comment:话题"`
	Content    string      `json:"content" form:"content" gorm:"column:content;comment:内容"`
	Release    int         `json:"release" form:"release" gorm:"column:release;comment:【文章发布状态，0-未发布，1-已发布，默认0】"`
	Time       int64       `json:"time" form:"time" gorm:"column:time;comment:发布时间"`
	Admin      Admin       `gorm:"foreignKey:AdminId;references:Id"` //一篇文章属于一个管理员，belongs to关系
	Categories []*Category `gorm:"many2many:topic_category;foreignKey:Id;joinForeignKey:TopicId;References:Id;joinReferences:CategoryId"`
}

func (Topic) TableName() string {
	return "topic"
}
